﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TemplateWeb.Models.ViewModels.GroupViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <% 
        var oUser = Model.UsersModel.GetModel.LstObjModel[0];
    %>
    <script type="text/javascript">
        <% if (ViewData["ChangeMsg"] != null && ViewData["ChangeMsg"].ToString() != ""){ %>
			alert('<%= ViewData["ChangeMsg"].ToString() %>');
		<% } %>

        function ValidateCheckout() {
            var total = <%= Model.ShoppingCartModel.CartTotal %>;
            if (total == 0) {
                alert("Giỏ hàng hiện thời chưa có sản phẩm nào nên không thể thực hiện chức năng thanh toán");
                return false;
            }
            var sotaikhoan = document.getElementsByName("Order_SoTaiKhoan").item(0).value;
            var mabaomat = document.getElementsByName("Order_MaBaoMat").item(0).value;
            if(sotaikhoan == ""){
                alert("Vui lòng nhập số tài khoản");
                return false;
            }
            if(mabaomat == ""){
                alert("Vui lòng nhập mã bảo mật");
                return false;
            }
            return true;
        }
    </script>
    <%
        var tennguoinhan = ViewData["Order_TenNguoiNhan"] == null ? string.Empty : ViewData["Order_TenNguoiNhan"].ToString();
        var diachinguoinhan = ViewData["Order_DiaChiNguoiNhan"] == null ? string.Empty : ViewData["Order_DiaChiNguoiNhan"].ToString();
        var sodienthoainguoinhan = ViewData["Order_SoDienThoaiNguoiNhan"] == null ? string.Empty : ViewData["Order_SoDienThoaiNguoiNhan"].ToString();
        var chuthich = ViewData["Order_ChuThich"] == null ? string.Empty : ViewData["Order_ChuThich"].ToString();
        var sotaikhoan = ViewData["Order_SoTaiKhoan"] == null ? string.Empty : ViewData["Order_SoTaiKhoan"].ToString();
        var mabaomat = ViewData["Order_MaBaoMat"] == null ? string.Empty : ViewData["Order_MaBaoMat"].ToString();
    %>
    <div class="content_panel">
        <div class="box_center">
            <div class="title">
                <span>Thông tin người nhận</span><div class="bg">
                    <img src="../../Content/Images/Home/bg_title_right.png"></div>
            </div>
            <div class="content">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tbody>
                        <tr>
                            <td valign="top">
                                <!-- MAIN -->
                                <br />
                                <% using (Html.BeginForm("AddOrder", "Home", FormMethod.Post, new { onsubmit = "return ValidateCheckout();" }))
                                   { %>
                                <table width="100%" border="0" cellpadding="0" cellspacing="0" style="text-align: left">
                                    <tbody>
                                        <tr>
                                            <td colspan="2" style="padding-left: 10px; padding-bottom: 10px;">
                                                <script language="javascript" type="text/javascript">
                                                    function showThongTinDaDangKy(chkbox) {
                                                        if (chkbox.checked) {
                                                            document.getElementsByName("Order_TenNguoiNhan").item(0).value = "<%= oUser.ExtraInfo.HoTen%>";
                                                            document.getElementsByName("Order_SoDienThoaiNguoiNhan").item(0).value = "<%= oUser.ExtraInfo.Phone%>";
                                                            document.getElementsByName("Order_DiaChiNguoiNhan").item(0).value = "<%= oUser.ExtraInfo.DiaChi%>";
                                                        } else {
                                                            document.getElementsByName("Order_TenNguoiNhan").item(0).value = "";
                                                            document.getElementsByName("Order_SoDienThoaiNguoiNhan").item(0).value = "";
                                                            document.getElementsByName("Order_DiaChiNguoiNhan").item(0).value = "";
                                                        }
                                                    } 
                                                </script>
                                                <input type="checkbox" id="ShowThongTinDangKy" onclick="showThongTinDaDangKy(this);" />
                                                Sử dụng thông tin đã đăng ký
                                            </td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                <div style="margin: 5px 10px;">
                                                    <b>Họ tên người nhận</b></div>
                                            </td>
                                            <td valign="top">
                                                <div style="margin: 5px 10px 5px 5px;">
                                                    <%= Html.TextBox("Order_TenNguoiNhan", tennguoinhan, new { style = "width: 340px;" })%>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                <div style="margin: 5px 10px;">
                                                    <b>SĐT người nhận</b></div>
                                            </td>
                                            <td valign="top">
                                                <div style="margin: 5px 10px 5px 5px;">
                                                    <%= Html.TextBox("Order_SoDienThoaiNguoiNhan", sodienthoainguoinhan, new { style = "width: 340px;" })%>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                <div style="margin: 5px 5px 5px 10px;">
                                                    <b>Địa chỉ người nhận</b></div>
                                            </td>
                                            <td valign="top">
                                                <div style="margin: 5px 10px 5px 5px;">
                                                    <%= Html.TextBox("Order_DiaChiNguoiNhan", diachinguoinhan, new { style = "width: 340px;" })%>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                <div style="margin: 5px 5px 5px 10px;">
                                                    <b>Ghi chú thêm</b></div>
                                            </td>
                                            <td valign="top">
                                                <div style="margin: 5px 10px 5px 5px;">
                                                    <%= Html.TextArea("Order_ChuThich", chuthich, new { style = "width: 340px; height: 100px;" })%>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                <div style="margin: 5px 5px 5px 10px;">
                                                    <b>Số tiền thanh toán</b></div>
                                            </td>
                                            <td valign="top">
                                                <div style="margin: 5px 10px 5px 5px;">
                                                    <input type="hidden" name="Order_TongTien" value="<%= Model.ShoppingCartModel.CartTotal %>" />
                                                    <%= string.Format("{0:0,0}", Model.ShoppingCartModel.CartTotal)%>
                                                    Đ
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                <div style="margin: 5px 10px;">
                                                    <b>Số tài khoản</b></div>
                                            </td>
                                            <td valign="top">
                                                <div style="margin: 5px 10px 5px 5px;">
                                                    <%= Html.TextBox("Order_SoTaiKhoan", sotaikhoan, new { style = "width: 340px;" })%>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                <div style="margin: 5px 10px;">
                                                    <b>Mã bảo mật</b></div>
                                            </td>
                                            <td valign="top">
                                                <div style="margin: 5px 10px 5px 5px;">
                                                    <%= Html.TextBox("Order_MaBaoMat", mabaomat, new { style = "width: 340px;" })%>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="20" style="width: 130px">
                                            </td>
                                            <td height="20">
                                                <div style="margin: 5px 10px 5px 5px;">
                                                    <br />
                                                    <input type="submit" name="sbt" id="sbt" value="Xác nhận" style="background-image: url(../../../Content/Images/Home/bgbutton.jpg);
                                                        color: #FFFFFF; font-size: 16px; font-weight: bold; border: 1px #DBDBDB solid;
                                                        height: 30px; cursor: pointer;" />
                                                    <p>
                                                    </p>
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                    <!-- MAIN END -->
                                </table>
                                <% } %>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</asp:Content>
